This page is under construction.
Migrating Your DreamFactory Instance
DreamFactory often acts as a reliable "set it and forget it" platform, running seamlessly for extended periods with minimal maintenance. However, there may be scenarios where you need to migrate your DreamFactory instance to a new server or environment. This guide outlines the migration process, focusing on two critical components: the .env
file and the DreamFactory system database.
Why Are the .env
File and System Database Important?
.env
File
The .env
file contains essential configuration settings for your DreamFactory instance, including:
- The APP_KEY
- Database credentials
- Caching preferences
- API keys
- Other environmental settings
The primary component of the
.env
file that we're interested in is theAPP_KEY
. Once we've migrated the system database, we can initilize the new DreamFactory instance with theAPP_KEY
from the old instance.
DreamFactory System Database
The DreamFactory system database stores:
- User accounts
- Scripts
- API configurations
- System-level metadata
Migrating these ensures your new DreamFactory instance contains all your original configurations and data, eliminating the need for manual recreation of your environment.
Step-by-Step Migration Guide
Step 1: Back Up the .env
File
-
Navigate to the DreamFactory root directory:
cd /opt/dreamfactory
-
Copy the
.env
file to a secure location:cp .env ~/.env
-
Use SFTP or another tool to transfer the
.env
file to an external location for safekeeping.
Tip: Storing a copy of the .env
file off-server ensures you can recover from any issues during the migration.
Step 2: Back Up the System Database
- Use the system database credentials from the
.env
file to back up the system database.
- MySQL
- MS SQL Server
- PostgreSQL
- SQLite
mysqldump -u df_admin -p --databases dreamfactory --no-create-db > ~/dump.sql
Use SSMS (SQL Server Management Studio) to export the database to a file.
pg_dump -U df_admin -d dreamfactory -F p > ~/dump.sql
sqlite3 dreamfactory.db ".dump" > ~/dump.sql
-
Replace
df_admin
with your database user, anddreamfactory
with your database name (if different). -
Transfer the backup file (
dump.sql
) to a secure external location, just as you did with the.env
file.
Step 3: Prepare the New DreamFactory Instance
- Set up a new server with a clean installation of your operating system (Linux, Docker, Windows, etc.)
- Follow the corresponding DreamFactory installation instructions for your operating system found in the install guide.
- Complete the initial setup by creating an administrator account. This account will be replaced with imported data.
Step 4: Additional Configuration
MySQL Specific Configuration
If your old instance used MySQL and you are upgrading versions (e.g., MySQL 5.6 to 5.7+), you may need to disable strict mode:
- Open the
config/database.php
file. - Add
'strict' => false
under the MySQL configuration section.
General Configuration
Ensure all system dependencies, such as PHP, are up to date. DreamFactory supports PHP 8.1 or later.
Step 5: Import the System Database Backup
-
Transfer the
dump.sql
file to the new server. -
Clear the default database schema:
php artisan migrate:fresh
php artisan migrate:reset
-
Import the database backup:
- MySQL
- MS SQL Server
- PostgreSQL
- SQLite
mysql -u df_admin -p dreamfactory < ~/dump.sql
Use SSMS (SQL Server Management Studio) to import the database from the file.
psql -U df_admin -d dreamfactory < ~/dump.sql
sqlite3 dreamfactory.db < ~/dump.sql
-
Run database migrations to apply schema updates:
php artisan migrate --seed
-
Replace the
APP_KEY
in the.env
file:APP_KEY=APP_KEY_FROM_OLD_INSTANCE
-
Clear caches to finalize the configuration:
php artisan cache:clear
php artisan config:clear
Final Steps
Log in to the new DreamFactory instance using credentials from the migrated environment. Confirm all APIs, configurations, and users have been successfully restored.
Congratulations! Your DreamFactory instance has been migrated successfully.